package Shell;


public class FileUtil {
	
	public Directory getDir(Directory src, String dest)
	{
		if(dest.indexOf('/') == -1) {
			for(Directory dir : src.getDirList())
				if(dir.getDirName().equals(dest))
					return dir;
		}
			
		String dirName = dest.substring(0, dest.indexOf('/'));
		dest = dest.substring(dest.indexOf('/')+1);
		
		for(Directory dir : src.getDirList()) {
			if(dir.getDirName().equals(dirName))
				return getDir(dir, dest);
		}
		
		return null;
	}
	
	public void showChildNames(Directory dir) {
		for(Directory child : dir.getDirList())
			System.out.println(child.getDirName());
		for(File file : dir.getFileList())
			System.out.println(file.getFileName());
	}
}
